use r2r::unitree_api::msg::Request;
use std::thread::sleep;
use std::time::Duration;
use unitree_ros2_rs::vui_client::client::VuiClient;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let vui_client = VuiClient::new("vui_blink_example", "")?;

    let mut req = Request::default();

    println!("Starting VUI blink demo...");

    // 第一下本来就是亮的，需要先关闭
    for i in 0..3 {
        println!("Blink {}/3: OFF", i + 1);
        vui_client.set_brightness(&mut req, 0); // Turn off
        sleep(Duration::from_millis(250));

        println!("Blink {}/3: ON", i + 1);
        vui_client.set_brightness(&mut req, 3); // Set brightness to 10 (you can adjust this value)
        sleep(Duration::from_millis(250));

        if i == 2{
            vui_client.set_brightness(&mut req, 0);
        }
    }

    println!("VUI blink demo finished.");

    Ok(())
}